package com.Monica.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ContextServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
//意思就是浏览器可以访问servlet目录
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletContext context = getServletConfig().getServletContext();
        String usname = context.getInitParameter("username");
        System.out.println("context-param参数username的值" + usname);
        System.out.println("context-param参数username的值" + context.getInitParameter("password"));
        System.out.println("当前工程的路径：" + context.getContextPath());

        System.out.println("工程部署的路径:" + context.getRealPath("/"));
        System.out.println("工程css目录的绝对路径是:" + context.getRealPath("/css"));
    }
}
